package controllers

import (
	"fmt"
	"strings"

	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
)

type LoginController struct {
	beego.Controller
}

// 登陆
func (l *LoginController) Get() {
	username := l.GetString("username")
	password := l.GetString("password")

	var cloumn []int
	o := orm.NewOrm()
	a := o.Raw("select * from user").QueryRow(&cloumn)

	fmt.Println(a)
	fmt.Println(len(cloumn))

	for i, v := range cloumn {
		fmt.Print(cloumn[i])
		fmt.Print(v)
	}

	fmt.Println(username, "|", password)

	if strings.EqualFold("admin", username); strings.EqualFold("123456", password) {
		l.Data["username"] = username
		l.Data["password"] = password
		l.TplName = "wellcome.tpl"
	} else {
		l.Data["message"] = "账号或密码错误！"
		l.TplName = "index.tpl"
	}

}
